<?php
namespace Summer\Hub\Http\Middleware;

use Closure;
use Summer\Hub\Http\Controllers\Traits\ApiReturn;
use Tymon\JWTAuth\Http\Middleware\BaseMiddleware;
use Exception;
use ApplicationException;

class HubJwtAuthMiddleware extends BaseMiddleware
{
    use ApiReturn;
    public function handle($request, Closure $next)
    {
        try {
            $this->authenticate($request);
        }catch (Exception $ex) {
            return $this->apiError($ex->getMessage(),[],401);
        }
        $response = $next($request);
        return $response;
    }
}
